static void
ReadGuid(gbfile* f, GUID* guid)
{
- int i = 0;
guid->l = ReadLong(f);
- for (i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
guid->s[i] = ReadShort(f);
}
- for (i = 0; i < 6; i++) {
+ for (int i = 0; i < 6; i++) {
guid->c[i] = ReadChar(f);
}
}
static void
WriteGuid(gbfile* f, GUID* guid)
{
- int i = 0;
WriteLong(f, guid->l);
- for (i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
WriteShort(f, guid->s[i]);
}
- for (i = 0; i < 6; i++) {
+ for (int i = 0; i < 6; i++) {
WriteChar(f, guid->c[i]);
}
}
static an1_waypoint_record* Alloc_AN1_Waypoint()
{
- an1_waypoint_record* result = nullptr;
- result = (an1_waypoint_record*)xcalloc(sizeof(*result), 1);
+ an1_waypoint_record* result = (an1_waypoint_record*)xcalloc(sizeof(*result), 1);
result->fs.type = FS_AN1W;
result->fs.copy = Copy_AN1_Waypoint;
result->fs.destroy = Destroy_AN1_Waypoint;
static an1_vertex_record* Alloc_AN1_Vertex()
{
- an1_vertex_record* result = nullptr;
- result = (an1_vertex_record*)xcalloc(sizeof(*result), 1);
+ an1_vertex_record* result = (an1_vertex_record*)xcalloc(sizeof(*result), 1);
result->fs.type = FS_AN1V;
result->fs.copy = Copy_AN1_Vertex;
result->fs.destroy = Destroy_AN1_Vertex;
static an1_line_record* Alloc_AN1_Line()
{
- an1_line_record* result = nullptr;
- result = (an1_line_record*)xcalloc(sizeof(*result), 1);
+ an1_line_record* result = (an1_line_record*)xcalloc(sizeof(*result), 1);
result->fs.type = FS_AN1L;
result->fs.copy = Copy_AN1_Line;
result->fs.destroy = Destroy_AN1_Line;
static void Read_AN1_Waypoints(gbfile* f)
{
- unsigned long count = 0;
- unsigned long i = 0;
- an1_waypoint_record* rec = nullptr;
Waypoint* wpt_tmp;
char* icon = nullptr;
ReadShort(f);
- count = ReadLong(f);
- for (i = 0; i < count; i++) {
- rec = Alloc_AN1_Waypoint();
+ unsigned long count = ReadLong(f);
+ for (unsigned long i = 0; i < count; i++) {
+ an1_waypoint_record* rec = Alloc_AN1_Waypoint();
Read_AN1_Waypoint(f, rec);
wpt_tmp = new Waypoint;
static void Read_AN1_Lines(gbfile* f)
{
- unsigned long count = 0;
- unsigned long i = 0;
- unsigned long j = 0;
- an1_line_record* rec = nullptr;
- an1_vertex_record* vert = nullptr;
route_head* rte_head;
Waypoint* wpt_tmp;
ReadShort(f);
- count = ReadLong(f);
- for (i = 0; i < count; i++) {
- rec = Alloc_AN1_Line();
+ unsigned long count = ReadLong(f);
+ for (unsigned long i = 0; i < count; i++) {
+ an1_line_record* rec = Alloc_AN1_Line();
Read_AN1_Line(f, rec);
/* create route rec */
rte_head = route_head_alloc();
rte_head->rte_name = rec->name;
fs_chain_add(&rte_head->fs, (format_specific_data*)rec);
route_add_head(rte_head);
- for (j = 0; j < (unsigned) rec->pointcount; j++) {
- vert = Alloc_AN1_Vertex();
+ for (unsigned long j = 0; j < (unsigned) rec->pointcount; j++) {
+ an1_vertex_record* vert = Alloc_AN1_Vertex();
Read_AN1_Vertex(f, vert);
/* create route point */
{
an1_line_record* rec;
int local;
- format_specific_data* fs = nullptr;
- fs = fs_chain_find(rte->fs, FS_AN1L);
+ format_specific_data* fs = fs_chain_find(rte->fs, FS_AN1L);
if (fs) {
rec = (an1_line_record*)(void*)fs;
{
an1_vertex_record* rec;
int local;
- format_specific_data* fs = nullptr;
- fs = fs_chain_find(wpt->fs, FS_AN1V);
+ format_specific_data* fs = fs_chain_find(wpt->fs, FS_AN1V);
if (fs) {
rec = (an1_vertex_record*)(void*)fs;
Init_Road_Changes()
{
int count = 0;
- char* strType = nullptr;
- char* name = nullptr;
- char* bar = nullptr;
- char* copy = nullptr;
Free_Road_Changes();
if (!road_changes || !road_changes[0]) {
return;
}
- bar = strchr(road_changes, '!');
+ char* bar = strchr(road_changes, '!');
while (bar) {
count++;
bar = strchr(bar+1, '!');
roadchanges[count].type = 0;
roadchanges[count].name = nullptr;
- copy = xstrdup(road_changes);
+ char* copy = xstrdup(road_changes);
bar = copy;
while (count) {
count--;
- name = bar;
+ char* name = bar;
bar = strchr(name, '!');
*bar = '\0';
bar++;
- strType = bar;
+ char* strType = bar;
bar = strchr(strType, '!');
if (bar) {
*bar = '\0';
static int FindIconByName(const char* name, GUID* guid)
{
- unsigned int i = 0;
- for (i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
+ for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
if (!case_ignore_strcmp(name, default_guids[i].name)) {
memcpy(guid, &(default_guids[i].guid), sizeof(GUID));
return 1;
static int FindIconByGuid(GUID* guid, char** name)
{
- unsigned int i = 0;
- for (i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
+ for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
if (!memcmp(guid, &default_guids[i].guid, sizeof(GUID))) {
*name = const_cast<char*>(default_guids[i].name);
return 1;
arcpt2->latitude = arcpt2->longitude = BADVAL;
while ((line = gbfgetstr(file_in))) {
- int argsfound = 0;
-
fileline++;
char* pound = strchr(line, '#');
}
arcpt2->latitude = arcpt2->longitude = BADVAL;
- argsfound = sscanf(line, "%lf %lf", &arcpt2->latitude, &arcpt2->longitude);
+ int argsfound = sscanf(line, "%lf %lf", &arcpt2->latitude, &arcpt2->longitude);
if (argsfound != 2 && strspn(line, " \t\n") < strlen(line)) {
warning(MYNAME ": Warning: Arc file contains unusable vertex on line %d.\n", fileline);
double frac;
double lat_dest;
double long_dest;
- Waypoint* wpt_dest = nullptr;
distance = radtometers(distance);
if (distance <= maxDist) {
return nullptr;
linepart(lat_orig, long_orig, lat_orig_adj, long_orig_adj, frac,
&lat_dest, &long_dest);
- wpt_dest = new Waypoint(*wpt_orig);
+ Waypoint* wpt_dest = new Waypoint(*wpt_orig);
wpt_dest->latitude = DEG(lat_dest);
wpt_dest->longitude = DEG(long_dest);
double lat_orig_next = RAD(wpt_orig_next->latitude);
double long_orig_next = RAD(wpt_orig_next->longitude);
- Waypoint* wpt_dest_next = nullptr;
if (is_small_angle(lat_orig, long_orig, lat_orig_prev,
long_orig_prev, lat_orig_next, long_orig_next)) {
route_add_wpt(route_dest, wpt_dest_prev);
}
- wpt_dest_next = create_wpt_dest(wpt_orig,
- lat_orig, long_orig, lat_orig_next, long_orig_next);
+ Waypoint* wpt_dest_next = create_wpt_dest(wpt_orig,
+ lat_orig, long_orig, lat_orig_next, long_orig_next);
if (wpt_dest_next != nullptr) {
route_add_wpt(route_dest, wpt_dest_next);
} else {
unsigned char bits = 0xc0;
unsigned char mask = 0xe0;
- int len = 0;
- for (len = 1; len <= 6; len++) { /* outer loop, test UTF-8 frame */
+ for (int len = 1; len <= 6; len++) { /* outer loop, test UTF-8 frame */
if ((*cp & mask) == bits) {
int i = len;
while (i-- > 0) {
route_head* track = nullptr;
while ((buff = gbfgetstr(fin))) {
- char* cin = buff;
char* ctail;
if ((line++ == 0) && fin->unicode) {
cet_convert_init(CET_CHARSET_UTF8, 1);
}
- cin = lrtrim(buff);
+ char* cin = lrtrim(buff);
if (strlen(cin) == 0) {
continue;
}
Waypoint* wpt = nullptr;
while ((buff = gbfgetstr(fin))) {
- char* cin = buff;
-
if ((line++ == 0) && fin->unicode) {
cet_convert_init(CET_CHARSET_UTF8, 1);
}
- cin = lrtrim(buff);
+ char* cin = lrtrim(buff);
if (strlen(cin) == 0) {
continue;
}
csv_stringtrim(const char* string, const char* enclosure, int strip_max)
{
static const char* p1 = nullptr;
- char* p2 = nullptr;
char* tmp = xxstrdup(string,file,line);
size_t elen;
int stripped = 0;
elen = strlen(enclosure);
}
- p2 = tmp + strlen(tmp) - 1;
+ char* p2 = tmp + strlen(tmp) - 1;
p1 = tmp;
/* trim off trailing whitespace */
QString
dec_to_human(const char* format, const char* dirs, double val)
{
- char* subformat = nullptr;
- const char* formatptr = nullptr;
- char* percent = nullptr;
- char* type = nullptr;
-
int index = 0;
int intvals[3] = {0,0,0};
double dblvals[3] = {0,0,0};
- int sign = 0;
- sign = (val < 0) ? 0 : 1;
+ int sign = (val < 0) ? 0 : 1;
dblvals[0] = fabs(val);
intvals[0] = (int)dblvals[0];
dblvals[2] = 60*(dblvals[1]-intvals[1]);
intvals[2] = (int)dblvals[2];
- subformat = (char*) xmalloc(strlen(format)+2);
- formatptr = format;
+ char* subformat = (char*) xmalloc(strlen(format)+2);
+ const char* formatptr = format;
QString buff;
while (formatptr && *formatptr) {
strcpy(subformat, formatptr);
- percent = strchr(subformat, '%');
+ char* percent = strchr(subformat, '%');
if (percent) {
- type = percent+1+strcspn(percent+1, "cdiouxXeEfgG%");
+ char* type = percent+1+strcspn(percent+1, "cdiouxXeEfgG%");
*(type+1) = '\0';
switch (*type) {
case 'c':
static int
inflate_buff(const char* buff, const size_t size, char** out_buff)
{
- int res = Z_OK;
z_stream strm;
char out[DEFLATE_BUFF_SIZE];
char* cout = nullptr;
strm.avail_in = 0;
strm.next_in = Z_NULL;
- res = inflateInit(&strm);
+ int res = inflateInit(&strm);
if (res != Z_OK) {
return res;
}
static mag_info*
explorist_ini_try(const char* path)
{
- mag_info* info = nullptr;
char* inipath;
char* s;
return nullptr;
}
- info = (mag_info*) xmalloc(sizeof(mag_info));
+ mag_info* info = (mag_info*) xmalloc(sizeof(mag_info));
info->geo_path = nullptr;
info->track_path = nullptr;
info->waypoint_path = nullptr;
void fs_chain_destroy(format_specific_data* chain)
{
format_specific_data* cur = chain;
- format_specific_data* next = nullptr;
while (cur) {
- next = cur->next;
+ format_specific_data* next = cur->next;
cur->destroy(cur);
cur = next;
}
route_head* head = nullptr;
while ((buff = gbfgetstr(fin))) {
- char* cin = buff;
char* cdata;
if ((line++ == 0) && fin->unicode) {
cet_convert_init(CET_CHARSET_UTF8, 1);
}
- cin = lrtrim(buff);
+ char* cin = lrtrim(buff);
if (!*cin) {
continue;
}
garmin_fs_t*
garmin_fs_alloc(const int protocol)
{
- garmin_fs_t* result = nullptr;
-
- result = (garmin_fs_t*)xcalloc(1, sizeof(*result));
+ garmin_fs_t* result = (garmin_fs_t*)xcalloc(1, sizeof(*result));
result->fs.type = FS_GMSD;
result->fs.copy = (fs_copy) garmin_fs_copy;
result->fs.destroy = garmin_fs_destroy;
void
garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid)
{
- garmin_fs_t* gmsd = nullptr;
-
- gmsd = garmin_fs_alloc(protoid);
+ garmin_fs_t* gmsd = garmin_fs_alloc(protoid);
fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
/* nothing happens until gmsd is allocated some lines above */
if (first == 0) {
short l1;
short l2;
- char* res2 = nullptr;
char lc1[3] = "";
char lc2[3] = "";
char* res1 = gpi_read_lc_string_old(lc1, &l1);
if ((l1 + 4) < l0) { // dual language?
- res2 = gpi_read_lc_string_old(lc2, &l2);
+ char* res2 = gpi_read_lc_string_old(lc2, &l2);
is_fatal((l1 + 4 + l2 + 4 != l0),
MYNAME ": Error out of sync (wrong size %d/%d/%d) on field '%s'!", l0, l1, l2, field);
if (opt_lang && (strcmp(opt_lang, lc1) == 0)) {
char* str;
int column = -1;
Waypoint* wpt;
- garmin_fs_p gmsd = nullptr;
bind_fields(waypt_header);
wpt = new Waypoint;
- gmsd = garmin_fs_alloc(-1);
+ garmin_fs_p gmsd = garmin_fs_alloc(-1);
fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
while ((str = csv_lineparse(nullptr, "\t", "", column++))) {
format_garmin_xt_rd_st_attrs(char* p_trk_name, uint8_t* p_track_color)
{
int method = 0;
- uint16_t trackbytes = 0, TrackPoints = 0;
uint8_t spam = 0;
int32_t TrackMaxLat = 0, TrackMaxLon = 0, TrackMinLat = 0, TrackMinLon = 0;
char trk_name[30]="";
// set to RED if not specified
*p_track_color=9;
- trackbytes = gbfgetuint16(fin);
- TrackPoints = gbfgetuint16(fin);
+ uint16_t trackbytes = gbfgetuint16(fin);
+ uint16_t TrackPoints = gbfgetuint16(fin);
(void) TrackPoints;
switch (method) {
static void
format_garmin_xt_decomp_trk_blk(uint8_t ii, uint8_t TrackBlock[], double* Ele, double* Lat, double* Lon, uint32_t* Time)
{
- uint32_t LatLW = 0, LonLW = 0, TimeLW = 0;
- double LatF = 0, LonF = 0;
uint16_t PrevEleW;
//printf("%d %d %d %d %d %d\n", TrackBlock[0], TrackBlock[1], TrackBlock[2], TrackBlock[3], TrackBlock[4], TrackBlock[5]);
PrevEleW = PrevEleW + TrackBlock[(ii - 1) * 12 ];
*Ele = (double)PrevEleW * GARMIN_XT_ELE - 1500;
- LatLW = TrackBlock[(ii - 1) * 12 + 4];
+ uint32_t LatLW = TrackBlock[(ii - 1) * 12 + 4];
LatLW = LatLW << 8;
LatLW = LatLW + TrackBlock[(ii - 1) * 12 + 3];
LatLW = LatLW << 8;
LatLW = LatLW + TrackBlock[(ii - 1) * 12 + 2];
- LatF = (double)LatLW;
+ double LatF = (double)LatLW;
if (LatF > 8388608) {
LatF = LatF - 16777216;
}
*Lat = LatF * 360 / 16777216;
- LonLW = TrackBlock[(ii-1)*12+7];
+ uint32_t LonLW = TrackBlock[(ii-1)*12+7];
LonLW = LonLW << 8;
LonLW = LonLW+TrackBlock[(ii-1)*12+6];
LonLW = LonLW << 8;
LonLW = LonLW+TrackBlock[(ii-1)*12+5];
- LonF = (double)LonLW;
+ double LonF = (double)LonLW;
if (LonF>8388608) {
LonF = LonF - 16777216;
}
*Lon = LonF * 360 / 16777216;
- TimeLW = TrackBlock[(ii - 1) * 12 + 11];
+ uint32_t TimeLW = TrackBlock[(ii - 1) * 12 + 11];
TimeLW = TimeLW << 8;
TimeLW = TimeLW+TrackBlock[(ii - 1) * 12 + 10];
TimeLW = TimeLW << 8;
format_garmin_xt_proc_strk()
{
int Count = 0; // Used to obtain number of read bytes
- int NumberOfTracks = 0, TracksCompleted = 0; // Number of tracks in the file and number of processed tracks
- uint16_t trackbytes = 0; // Bytes in track
+ int TracksCompleted = 0; // Number of tracks in the file and number of processed tracks
uint8_t TrackBlock[STRK_BLOCK_SIZE + 1]; // File Block
uint8_t ii; // temp variable
double Lat = 0, Lon = 0; // wpt data
gbfseek(fin, 12, SEEK_SET);
// read # of tracks
- NumberOfTracks = gbfgetuint16(fin);
+ int NumberOfTracks = gbfgetuint16(fin);
// Skip 2 bytes
gbfseek(fin, 2, SEEK_CUR);
trk_name = (char*) xmalloc(30);
// Generate Track Header
- trackbytes = format_garmin_xt_rd_st_attrs(trk_name, &trk_color) - 50;
+ uint16_t trackbytes = format_garmin_xt_rd_st_attrs(trk_name, &trk_color) - 50;
tmp_track = route_head_alloc();
// update track color
static void
format_garmin_xt_proc_atrk()
{
- uint16_t block=0, uu=0;
- uint32_t Lat=0, Lon=0;
- uint32_t Tim=0;
- double LatF = 0, LonF = 0, AltF = 0;
Waypoint* wpt;
int method = 0;
unsigned char buf[3];
num_trackpoints = gbfgetuint32(fin);
while (num_trackpoints--) {
- block = gbfgetuint16(fin);
+ uint16_t block = gbfgetuint16(fin);
if (block != 0x0c) {
break;
}
gbfread(&buf, 3, DATABLOCKSIZE, fin); //1. Lat
- Lat = buf[0] | (buf[1] << 8) | (buf[2] << 16);
+ uint32_t Lat = buf[0] | (buf[1] << 8) | (buf[2] << 16);
gbfread(&buf, 3, DATABLOCKSIZE, fin); //2. Lon
- Lon = buf[0] | (buf[1] << 8) | (buf[2] << 16);
+ uint32_t Lon = buf[0] | (buf[1] << 8) | (buf[2] << 16);
- uu = gbfgetuint16(fin);
- Tim = gbfgetuint32(fin);
+ uint16_t uu = gbfgetuint16(fin);
+ uint32_t Tim = gbfgetuint32(fin);
Tim += 631065600; // adjustment to UnixTime
- LatF = Lat;
+ double LatF = Lat;
if (LatF>8388608) {
LatF -= 16777216;
};
- LonF = Lon;
+ double LonF = Lon;
if (LonF>8388608) {
LonF -= 16777216;
};
- AltF = (double)uu * GARMIN_XT_ELE - 1500;
+ double AltF = (double)uu * GARMIN_XT_ELE - 1500;
//create new waypoint
wpt = new Waypoint;
uint8_t trackDeviceCommand;
int track_length;
- uint8_t* track_payload = nullptr;
- track_payload = globalsat_read_package(&track_length, &trackDeviceCommand);
+ uint8_t* track_payload = globalsat_read_package(&track_length, &trackDeviceCommand);
is_fatal(((track_length == 0) || (track_payload == nullptr)) , "tracklength in 0 bytes or payload nonexistant");
// printf("Got track package!!! Train data\n");
int off_hr = 0;
int off_min = 0;
int off_sign = 1;
- char* offsetstr = nullptr;
- char* pointstr = nullptr;
char* timestr = xstrdup(dateTimeString);
- offsetstr = strchr(timestr, 'Z');
+ char* offsetstr = strchr(timestr, 'Z');
if (offsetstr) {
/* zulu time; offsets stay at defaults */
*offsetstr = '\0';
}
double fsec = 0;
- pointstr = strchr(timestr, '.');
+ char* pointstr = strchr(timestr, '.');
if (pointstr) {
sscanf(pointstr, "%le", &fsec);
#if 0
void free_gpx_extras(xml_tag* tag)
{
- xml_tag* next = nullptr;
char** ap;
while (tag) {
xfree(tag->attributes);
}
- next = tag->sibling;
+ xml_tag* next = tag->sibling;
delete tag;
tag = next;
}
#define MAX_STRINGLEN 255
static char strOut[MAX_STRINGLEN];
char strTmp[MAX_STRINGLEN];
- char* shortstr = nullptr;
if (sLen > MAX_STRINGLEN) {
return (stIn);
setshort_length(mkshort_handle, sLen);
setshort_mustuniq(mkshort_handle, 0);
- shortstr = mkshort(mkshort_handle, stIn);
+ char* shortstr = mkshort(mkshort_handle, stIn);
strcpy(strTmp,shortstr);
xfree(shortstr);
int32_t utmz;
double utme, utmn;
char utmzc;
- fs_xml* fs_gpx = nullptr;
GPS_Math_WGS84_To_UTM_EN(wpt->latitude, wpt->longitude,
gbfprintf(file_out, "<p class=\"gpsbabelnotes\">%s</p>\n", CSTRc(wpt->notes));
}
- fs_gpx = nullptr;
+ fs_xml* fs_gpx = nullptr;
if (includelogs) {
fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX);
}
if (fs_gpx && fs_gpx->tag) {
xml_tag* root = fs_gpx->tag;
- xml_tag* curlog = nullptr;
- xml_tag* logpart = nullptr;
- curlog = xml_findfirst(root, "groundspeak:log");
+ xml_tag* curlog = xml_findfirst(root, "groundspeak:log");
while (curlog) {
time_t logtime = 0;
- struct tm* logtm = nullptr;
gbfprintf(file_out, "<p class=\"gpsbabellog\">\n");
- logpart = xml_findfirst(curlog, "groundspeak:type");
+ xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type");
if (logpart) {
gbfprintf(file_out, "<span class=\"gpsbabellogtype\">%s</span> by ", CSTR(logpart->cdata));
}
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
logtime = xml_parse_time(logpart->cdata).toTime_t();
- logtm = localtime(&logtime);
+ struct tm* logtm = localtime(&logtime);
if (logtm) {
gbfprintf(file_out,
"<span class=\"gpsbabellogdate\">%04d-%02d-%02d</span><br>\n",
logpart = xml_findfirst(curlog, "groundspeak:log_wpt");
if (logpart) {
- char* coordstr = nullptr;
double lat = 0;
double lon = 0;
- coordstr = xml_attribute(logpart, "lat");
+ char* coordstr = xml_attribute(logpart, "lat");
if (coordstr) {
lat = atof(coordstr);
}
logpart = xml_findfirst(curlog, "groundspeak:text");
if (logpart) {
- char* encstr = nullptr;
- int encoded = 0;
- encstr = xml_attribute(logpart, "encoded");
- encoded = (toupper(encstr[0]) != 'F');
+ char* encstr = xml_attribute(logpart, "encoded");
+ int encoded = (toupper(encstr[0]) != 'F');
QString s;
if (html_encrypt && encoded) {
humminbird_trk_point_t* points;
route_head* trk;
Waypoint* first_wpt;
- int max_points = 0;
int32_t accum_east;
int32_t accum_north;
double g_lat;
th.ne_east = be_read32(&th.ne_east);
th.ne_north = be_read32(&th.ne_north);
- max_points = (131080 - sizeof(uint32_t) - sizeof(th)) / sizeof(humminbird_trk_point_t);
+ int max_points = (131080 - sizeof(uint32_t) - sizeof(th)) / sizeof(humminbird_trk_point_t);
if (th.num_points == max_points + 1) {
th.num_points--;
humminbird_trk_point_old_t* points;
route_head* trk;
Waypoint* first_wpt;
- int max_points = 0;
int32_t accum_east;
int32_t accum_north;
double g_lat;
// These files are always 8048 bytes long. Note that that's the value
// of the second 16-bit word in the signature.
- max_points = (file_len - (sizeof(th) + sizeof(uint32_t) + TRK_NAME_LEN)) / sizeof(humminbird_trk_point_old_t);
+ int max_points = (file_len - (sizeof(th) + sizeof(uint32_t) + TRK_NAME_LEN)) / sizeof(humminbird_trk_point_old_t);
if (th.num_points > max_points) {
fatal(MYNAME ": Too many track points! (%d)\n", th.num_points);
}
QUEUE_FOR_EACH(backuproute, elem, tmp) {
- bool first = false;
route_head* rte_old = (route_head*)elem;
route_head* rte_new = route_head_alloc();
} else {
track_add_head(rte_new);
}
- first = 1;
+ bool first = 1;
QUEUE_FOR_EACH(&rte_old->waypoint_list, elem2, tmp2) {
Waypoint* wpt = (Waypoint*)elem2;
if (first) {
Waypoint* wpt;
struct tm tm;
char* tmp;
- int column = -1;
char valid = 'V';
double lat, lon;
float speed, course, mcourse, mvar, mdev;
speed = course = mcourse = mvar = mdev = -1;
mvardir = mdevdir = 0;
- column = -1;
+ int column = -1;
tmp = str;
while ((str = csv_lineparse(tmp, ",", "", column++))) {
tmp = nullptr;
void wpt_coord(const QString& args, const QXmlStreamAttributes*)
{
- int n = 0;
double lat, lon, alt;
if (! wpt_tmp) {
return;
}
// Alt is actually optional.
- n = sscanf(CSTRc(args), "%lf,%lf,%lf", &lon, &lat, &alt);
+ int n = sscanf(CSTRc(args), "%lf,%lf,%lf", &lon, &lat, &alt);
if (n >= 2) {
wpt_tmp->latitude = lat;
wpt_tmp->longitude = lon;
QString r;
fs_xml* fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX);
- xml_tag* root = nullptr;
- xml_tag* curlog = nullptr;
- xml_tag* logpart = nullptr;
if (!fs_gpx) {
return r;
}
- root = fs_gpx->tag;
- curlog = xml_findfirst(root, "groundspeak:log");
+ xml_tag* root = fs_gpx->tag;
+ xml_tag* curlog = xml_findfirst(root, "groundspeak:log");
while (curlog) {
// Unless we have a broken GPX input, these logparts
// branches will always be taken.
- logpart = xml_findfirst(curlog, "groundspeak:type");
+ xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type");
if (logpart) {
r = r + "<p><b>" + logpart->cdata + "</b>";
}
logpart = xml_findfirst(curlog, "groundspeak:text");
if (logpart) {
- int encoded = 0;
char* encstr = xml_attribute(logpart, "encoded");
- encoded = (toupper(encstr[0]) != 'F');
+ int encoded = (toupper(encstr[0]) != 'F');
QString s;
if (html_encrypt && encoded) {
static void
lowranceusr4_writestr(const QString& buf, gbfile* file, unsigned int bytes_per_char)
{
- unsigned int len = 0;
-
- len = buf.length();
+ unsigned int len = buf.length();
if (0xffffffff / bytes_per_char < len) {
/* be pedantic and check for the unlikely event that we are asked
int hms=0;
int fracsec=0;
int date=0;
- struct tm* tm = nullptr;
ilat = waypointp->latitude;
ilon = waypointp->longitude;
- tm = nullptr;
+ struct tm* tm = nullptr;
if (waypointp->creation_time.isValid()) {
const time_t ct = waypointp->GetCreationTime().toTime_t();
tm = gmtime(&ct);
static void
mapsend_waypt_pr(const Waypoint* waypointp)
{
- unsigned int c = 0;
double falt;
static int cnt = 0;
QString sn = global_opts.synthesize_shortnames ?
// This is funny looking to ensure that no more than 30 bytes
// get written to the file.
- c = waypointp->description.length();
+ unsigned int c = waypointp->description.length();
if (c > 30) {
c = 30;
}
static void
mps_route_wpt_w_unique_wrapper(const Waypoint* wpt)
{
- Waypoint* wptfound = nullptr;
-
/* Search for this waypoint in the ones already written */
- wptfound = mps_find_wpt_q_by_name(&written_wpt_head, CSTRc(wpt->shortname));
+ Waypoint* wptfound = mps_find_wpt_q_by_name(&written_wpt_head, CSTRc(wpt->shortname));
if (wptfound == nullptr)
/* so, not a real wpt, so must check route wpts already written as reals */
{
QString description;
QString shortname;
int faked_fsdata = 0;
- ozi_fsdata* fs = nullptr;
int icon = 0;
- fs = (ozi_fsdata*) fs_chain_find(wpt->fs, FS_OZI);
+ ozi_fsdata* fs = (ozi_fsdata*) fs_chain_find(wpt->fs, FS_OZI);
if (!fs) {
fs = ozi_alloc_fsdata();
olat = olon = lat1 = lon1 = lat2 = lon2 = BADVAL;
while ((line = gbfgetstr(file_in))) {
- char* pound = nullptr;
- int argsfound = 0;
-
fileline++;
- pound = strchr(line, '#');
+ char* pound = strchr(line, '#');
if (pound) {
*pound = '\0';
}
lat2 = lon2 = BADVAL;
- argsfound = sscanf(line, "%lf %lf", &lat2, &lon2);
+ int argsfound = sscanf(line, "%lf %lf", &lat2, &lon2);
if (argsfound != 2 && strspn(line, " \t\n") < strlen(line)) {
warning(MYNAME
unsigned int trk_num;
struct tm tmTime;
- time_t dateTime = 0;
- route_head* track_head = nullptr;
Waypoint* thisWaypoint;
psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), ltrimEOL);
rtrim(trkname);
trk_num = 0;
- track_head = nullptr;
+ route_head* track_head = nullptr;
psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), wscomma);
&(tmTime.tm_sec));
tmTime.tm_isdst = 0;
- dateTime = mkgmtime(&tmTime);
+ time_t dateTime = mkgmtime(&tmTime);
psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), whitespace);
struct ll mylatlon;
uint16_t coordcount;
route_head* track_head = nullptr;
- route_head* old_track_head = nullptr;
Waypoint* wpt_tmp;
char* routename = nullptr;
double seglen = 0.0;
double totaldist = 0.0;
double oldlat = 0;
double oldlon = 0;
- int first = 0;
ReadShort(infile); /* magic */
version = ReadShort(infile);
}
}
while (count) {
- old_track_head = nullptr;
+ route_head* old_track_head = nullptr;
ReadShort(infile);
recsize = ReadLong(infile);
record = ReadRecord(infile, recsize);
coordcount--;
}
- first = 1;
+ int first = 1;
while (coordcount) {
double lat;
static Waypoint*
decode_sbn_record(unsigned char* buffer)
{
- Waypoint* waypt = nullptr;
- waypt = new Waypoint;
+ Waypoint* waypt = new Waypoint;
if (is_sbn_valid(buffer)) {
waypt->fix = decode_sbn_mode(buffer + 3);
{
// an0008-1.4.14: logs if
// (dt > tmin & dd >= dmin & v >= vmin) | dt > tmax | dd > dmax | v > vmax
- unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000, nn=0;
+ unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000;
static uint8_t MSG_LOG_CONFIGURE_CONTROL[] = {
0x18, // message_id
0x00, 0x00, 0x0e, 0x10, // max_time: was 0x0000ffff (big endian!)
if (opt_configure_logging) {
if (*opt_configure_logging) {
- nn = sscanf(opt_configure_logging, "%u:%u:%u:%u", &tmin, &tmax, &dmin, &dmax);
+ unsigned int nn = sscanf(opt_configure_logging, "%u:%u:%u:%u", &tmin, &tmax, &dmin, &dmax);
if (nn>3) {
db(0, "Reconfiguring logging to: tmin=%u, tmax=%u, dmin=%u, dmax=%u\n", tmin, tmax, dmin, dmax);
be_write32(MSG_LOG_CONFIGURE_CONTROL+5, tmin);
int opt_first_sector_val = atoi(opt_first_sector);
int opt_last_sector_val = atoi(opt_last_sector);
int multi_read_supported = 1;
- uint8_t* buffer = nullptr;
gbfile* dumpfile = nullptr;
state_init(&st);
}
}
- buffer = (uint8_t*) xmalloc(SECTOR_SIZE*read_at_once+sizeof(SECTOR_READ_END)+6);
+ uint8_t* buffer = (uint8_t*) xmalloc(SECTOR_SIZE*read_at_once+sizeof(SECTOR_READ_END)+6);
// m.ad/090930: removed code that tried reducing read_at_once if necessary since doesn't work with xmalloc
if (opt_dump_file) {
void SimplifyRouteFilter::compute_xte(struct xte* xte_rec)
{
const Waypoint* wpt3 = xte_rec->intermed->wpt;
- const Waypoint* wpt1 = nullptr;
- const Waypoint* wpt2 = nullptr;
double frac, reslat, reslon;
/* if no previous, this is an endpoint and must be preserved. */
if (!xte_rec->intermed->prev) {
xte_rec->distance = HUGEVAL;
return;
}
- wpt1 = xte_rec->intermed->prev->wpt;
+ const Waypoint* wpt1 = xte_rec->intermed->prev->wpt;
/* if no next, this is an endpoint and must be preserved. */
if (!xte_rec->intermed->next) {
xte_rec->distance = HUGEVAL;
return;
}
- wpt2 = xte_rec->intermed->next->wpt;
+ const Waypoint* wpt2 = xte_rec->intermed->next->wpt;
if (xteopt) {
xte_rec->distance = radtomiles(linedist(
finalize_tracks(void)
{
Waypoint** list;
- int count = 0;
queue* elem, *tmp;
int index;
route_head* track = nullptr;
int trackno = 0;
- count = 0;
+ int count = 0;
QUEUE_FOR_EACH(&trackpts, elem, tmp) {
count++;
};
if (fs_gpx && fs_gpx->tag) {
xml_tag* root = fs_gpx->tag;
- xml_tag* curlog = nullptr;
- xml_tag* logpart = nullptr;
- curlog = xml_findfirst(root, "groundspeak:log");
+ xml_tag* curlog = xml_findfirst(root, "groundspeak:log");
while (curlog) {
time_t logtime = 0;
- struct tm* logtm = nullptr;
gbfprintf(file_out, "\n");
- logpart = xml_findfirst(curlog, "groundspeak:type");
+ xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type");
if (logpart) {
gbfputs(logpart->cdata, file_out);
gbfputs(" by ", file_out);
logpart = xml_findfirst(curlog, "groundspeak:date");
if (logpart) {
logtime = xml_parse_time(logpart->cdata).toTime_t();
- logtm = localtime(&logtime);
+ struct tm* logtm = localtime(&logtime);
if (logtm) {
gbfprintf(file_out,
"%4.4d-%2.2d-%2.2d\n",
logpart = xml_findfirst(curlog, "groundspeak:log_wpt");
if (logpart) {
- char* coordstr = nullptr;
double lat = 0;
double lon = 0;
- coordstr = xml_attribute(logpart, "lat");
+ char* coordstr = xml_attribute(logpart, "lat");
if (coordstr) {
lat = atof(coordstr);
}
logpart = xml_findfirst(curlog, "groundspeak:text");
if (logpart) {
- char* encstr = nullptr;
- int encoded = 0;
- encstr = xml_attribute(logpart, "encoded");
- encoded = (toupper(encstr[0]) != 'F');
+ char* encstr = xml_attribute(logpart, "encoded");
+ int encoded = (toupper(encstr[0]) != 'F');
QString s;
if (txt_encrypt && encoded) {
newblock->maxlat = maxlat;
newblock->size = 4 * 5 + 1; /* hdr is 5 longs, 1 char */
if (count < 20) {
- Waypoint* wpt = nullptr;
-
for (int i = 0; i < count; i++) {
newblock->size += 4 * 3 + 1;
/* wpt const part 3 longs, 1 char */
- wpt = start[i].wpt;
+ Waypoint* wpt = start[i].wpt;
newblock->size += wpt->description.length() + 1;
}
} else {
int lon = 0;
route_head* track_temp;
char rgb[7],bgr[7];
- int bbggrr = 0;
// Allocate the track struct
track_temp = route_head_alloc();
// RGB line_color expressed for html=rrggbb and kml=bbggrr - not assigned before 2012
sprintf(rgb,"%02x%02x%02x",styles[track_style].color[0],styles[track_style].color[1],styles[track_style].color[2]);
sprintf(bgr,"%02x%02x%02x",styles[track_style].color[2],styles[track_style].color[1],styles[track_style].color[0]);
- bbggrr = styles[track_style].color[2] << 16 | styles[track_style].color[1] << 8 | styles[track_style].color[0];
+ int bbggrr = styles[track_style].color[2] << 16 | styles[track_style].color[1] << 8 | styles[track_style].color[0];
track_temp->line_color.bbggrr = bbggrr;
// track texture (dashed=1, solid=0) mapped into opacity - not assigned before 2012
// Read/process each route in the file
//
for (unsigned int ii = 0; ii < route_count; ii++) {
- unsigned int name_length = 0;
unsigned int waypoint_cnt;
route_head* route_temp;
//UNKNOWN DATA LENGTH
// Fetch name length
- name_length = tpo_read_int();
+ unsigned int name_length = tpo_read_int();
QString route_name;
if (name_length) {
gbfread(route_name, 1, name_length, tpo_file_in);
{
// TODO: clean up this back and forth between QString and char*.
char* buf = nullptr;
- char* cbuf_start = nullptr;
const cet_cs_vec_t* ascii = &cet_cs_vec_ansi_x3_4_1968; /* us-ascii */
/* Convert the entire header to lower case for convenience.
} else if (s.contains('|')) {
unicsv_fieldsep = "|";
}
- cbuf_start = xstrdup(s.toLower());
+ char* cbuf_start = xstrdup(s.toLower());
const char* cbuf = cbuf_start;
/* convert the header line into native ascii */
static void
unicsv_parse_one_line(char* ibuf)
{
- Waypoint* wpt = nullptr;
int column;
int utm_zone = -9999;
double utm_easting = 0;
int ns = 1;
int ew = 1;
geocache_data* gc_data = nullptr;
- wpt = new Waypoint;
+ Waypoint* wpt = new Waypoint;
wpt->latitude = unicsv_unknown;
wpt->longitude = unicsv_unknown;
memset(&ymd, 0, sizeof(ymd));
struct one_line_advanced_mode adv;
char text[200]; /* used to read the header line, which is normal text */
} line;
- int is_advanced_mode = 0;
int lc = 0;
route_head* track;
if (!fgets(line.text, sizeof(line), fin)) {
fatal("v900: error reading header (first) line from input file\n");
}
- is_advanced_mode = (nullptr != strstr(line.text,"PDOP")); /* PDOP field appears only in advanced mode */
+ int is_advanced_mode = (nullptr != strstr(line.text,"PDOP")); /* PDOP field appears only in advanced mode */
v900_log("header line: %s",line.text);
v900_log("is_advance_mode=%d\n",is_advanced_mode);
{
vecs_t** svp;
int vc;
- int i = 0;
svp = sort_and_unify_vecs(&vc);
- for (i=0; i<vc; i++) {
+ for (int i = 0; i<vc; i++) {
if (svp[i]->vec->type == ff_type_internal) {
continue;
}
{
vecs_t** svp;
int vc;
- int i = 0;
svp = sort_and_unify_vecs(&vc);
- for (i=0; i<vc; i++) {
+ for (int i = 0; i<vc; i++) {
if (case_ignore_strcmp(svp[i]->name, vecname)) {
continue;
}
static void
vitosmt_read()
{
- long version =0;
- long subversion =0;
- long check1 =-1;
- long check2 =-2;
- long check3 =-3;
route_head* route_head =nullptr;
- Waypoint* wpt_tmp =nullptr;
- unsigned char* timestamp =nullptr;
struct tm tmStruct;
- double speed = 0.0;
- double course = 0.0;
- double pdop = 0.0;
- unsigned char gpsfix = 0;
- unsigned char gpsvalid = 0;
- unsigned char gpssats = 0;
int serial =0;
/*
* 24 bytes header
*/
- version = gbfgetint32(infile); /* 2 */
- subversion = gbfgetint32(infile); /* 1000 */
+ long version = gbfgetint32(infile); /* 2 */
+ long subversion = gbfgetint32(infile); /* 1000 */
count = gbfgetint32(infile); /* n */
- check1 = gbfgetint32(infile); /* 0 */
- check2 = gbfgetint32(infile); /* not sure */
+ long check1 = gbfgetint32(infile); /* 0 */
+ long check2 = gbfgetint32(infile); /* not sure */
(void) check2; // silence warning.
- check3 = gbfgetint32(infile); /* n */
+ long check3 = gbfgetint32(infile); /* n */
if (version!=vitosmt_version) {
double latrad = gbfgetdbl(infile); /* WGS84 latitude in radians */
double lonrad = gbfgetdbl(infile); /* WGS84 longitude in radians */
double elev = gbfgetdbl(infile); /* elevation in meters */
- timestamp = ReadRecord(infile,5); /* UTC time yr/mo/dy/hr/mi */
+ unsigned char* timestamp = ReadRecord(infile,5); /* UTC time yr/mo/dy/hr/mi */
double seconds = gbfgetdbl(infile); /* seconds */
- speed = gbfgetdbl(infile); /* speed in knots */
- course = gbfgetdbl(infile); /* course in degrees */
- pdop = gbfgetdbl(infile); /* dilution of precision */
- gpsfix = gbfgetc(infile); /* fix type x08,x10, x20 */
- gpsvalid = gbfgetc(infile); /* fix is valid */
- gpssats = gbfgetc(infile); /* number of sats */
+ double speed = gbfgetdbl(infile); /* speed in knots */
+ double course = gbfgetdbl(infile); /* course in degrees */
+ double pdop = gbfgetdbl(infile); /* dilution of precision */
+ unsigned char gpsfix = gbfgetc(infile); /* fix type x08,x10, x20 */
+ unsigned char gpsvalid = gbfgetc(infile); /* fix is valid */
+ unsigned char gpssats = gbfgetc(infile); /* number of sats */
- wpt_tmp = new Waypoint;
+ Waypoint* wpt_tmp = new Waypoint;
wpt_tmp->latitude =DEG(latrad);
wpt_tmp->longitude =DEG(lonrad);
static void
vitosmt_waypt_pr(const Waypoint* waypointp)
{
- unsigned char* workbuffer =nullptr;
size_t position =0;
double seconds =0;
++count;
- workbuffer = (unsigned char*) xcalloc(vitosmt_datasize,1);
+ unsigned char* workbuffer = (unsigned char*) xcalloc(vitosmt_datasize,1);
WriteDouble(&workbuffer[position], RAD(waypointp->latitude));
position += sizeof(double);
static void
vitosmt_write()
{
- unsigned char* workbuffer = nullptr;
-
- workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1);
+ unsigned char* workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1);
count = 0;
static void
vitovtt_read()
{
- route_head* route_head= nullptr;
- Waypoint* wpt_tmp = nullptr;
struct tm tmStruct;
memset(&tmStruct, 0, sizeof(tmStruct));
- route_head = route_head_alloc();
+ route_head* route_head = route_head_alloc();
track_add_head(route_head);
/* Read the header. */
int course = gbfgetint16(infile);
int status = gbfgetint32(infile);
- wpt_tmp = new Waypoint;
+ Waypoint* wpt_tmp = new Waypoint;
wpt_tmp->latitude= scaled_lat / vitovtt_latitudescale;
wpt_tmp->longitude= scaled_lon / vitovtt_longitudescale;
uint32_t tim;
double lat, lon, alt;
time_t rtim;
- Waypoint* tpt = nullptr;
const char* bp = (const char*) buf;
size_t buf_used = fmt_version[fmt].reclen;
st->route_head_ = nullptr;
}
- tpt = make_trackpoint(st, lat, lon, alt, rtim);
+ Waypoint* tpt = make_trackpoint(st, lat, lon, alt, rtim);
if (nullptr == st->route_head_) {
db(1, "New Track\n");
uint16_t flags;
double lat, lon, alt;
time_t rtim;
- Waypoint* tpt = nullptr;
const char* bp = (const char*) buf;
/* Zero records are skipped */
st->route_head_ = nullptr;
}
- tpt = make_trackpoint(st, lat, lon, alt, rtim);
+ Waypoint* tpt = make_trackpoint(st, lat, lon, alt, rtim);
if (nullptr == st->route_head_) {
db(1, "New Track\n");
void wfff_e(xg_string, const QXmlStreamAttributes*)
{
- Waypoint* wpt_tmp =nullptr;
char desc[255] ="\0";
if ((ap_hdop>=1)&&(ap_hdop<50)) { // Discard invalid GPS fix
- wpt_tmp = new Waypoint;
+ Waypoint* wpt_tmp = new Waypoint;
if (snmac) {
wpt_tmp->shortname = ap_mac;
{
queue* elem, *tmp;
field_map_t* fmp;
- int internal = 0;
/*
* If this xcsv_file struct came from a file we can free it all.
}
/* return everything to zeros */
- internal = xcsv_file.is_internal;
+ int internal = xcsv_file.is_internal;
xcsv_file.is_internal = internal;
}
static void
free_xml_tag(xml_tag* tag)
{
- xml_tag* next = nullptr;
char** ap;
while (tag) {
xfree(tag->attributes);
}
- next = tag->sibling;
+ xml_tag* next = tag->sibling;
delete tag;
tag = next;
}
static void
copy_xml_tag(xml_tag** copy, xml_tag* src, xml_tag* parent)
{
- xml_tag* res = nullptr;
- char** ap = nullptr;
-
if (!src) {
*copy = nullptr;
return;
}
- res = new xml_tag;
+ xml_tag* res = new xml_tag;
*copy = res;
// memcpy(res, src, sizeof(xml_tag));
res->cdata = (src->cdata);
res->parentcdata = (src->parentcdata);
if (src->attributes) {
- ap = src->attributes;
+ char** ap = src->attributes;
int count = 0;
while (*ap) {
count++;
static void
convert_xml_tag(xml_tag* tag)
{
- char** ap = nullptr;
-
if (tag == nullptr) {
return;
}
tag->cdata = tag->cdata;
tag->parentcdata = tag->parentcdata;
- ap = tag->attributes;
+ char** ap = tag->attributes;
while (*ap) {
*ap = cet_convert_string(*ap);
ap++;